package com.lineage.server.timecontroller.pet;

import com.lineage.server.model.Instance.L1DollInstance;
import com.lineage.server.thread.GeneralThreadPool;
import com.lineage.server.world.WorldDoll;
import java.util.Collection;
import java.util.Iterator;
import java.util.TimerTask;
import java.util.concurrent.ScheduledFuture;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class DollAidTimer extends TimerTask {
  private static final Log _log = LogFactory.getLog(DollAidTimer.class);
  
  private ScheduledFuture<?> _timer;
  
  public void start() {
    int timeMillis = 10000;
    this._timer = GeneralThreadPool.get().scheduleAtFixedRate(this, 10000L, 10000L);
  }
  
  public void run() {
    try {
      Collection<L1DollInstance> allDoll = WorldDoll.get().all();
      if (allDoll.isEmpty())
        return; 
      Iterator<L1DollInstance> iter = allDoll.iterator();
      while (iter.hasNext()) {
        L1DollInstance doll = iter.next();

        doll.startDollSkill(); 

//        doll.startDollAddSkill();
         Thread.sleep(50L);
      } 
    } catch (Exception e) {
      _log.error("魔法娃娃处理时间轴(辅助技能)异常重启", e);
      GeneralThreadPool.get().cancel(this._timer, false);
      DollAidTimer dollTimer = new DollAidTimer();
      dollTimer.start();
    } 
  }
}
